package com.ds.listener;

import com.ds.esb.config.EsbBeanAnnotation;
import com.ds.esb.config.EsbFlowType;
import com.ds.home.EIDevice;
import com.ds.home.engine.GWEngine;
import com.ds.home.event.GatewayEvent;
import com.ds.home.event.GatewayListener;
import com.ds.iot.HomeException;
import com.ds.iot.ZNode;
import com.ds.iot.enums.DeviceStatus;

@EsbBeanAnnotation(id = "SyncGatewayListener", name = "同步网关登录信息", flowType = EsbFlowType.listener, expressionArr = "SyncGatewayListener()", desc = "同步网关登录信息")
public class SyncGatewayListener implements GatewayListener {

    @Override
    public void gatewayOnLine(GatewayEvent event) throws HomeException {
        ZNode znode = event.getSource();
        EIDevice device = GWEngine.getDefaultEngine().getDeviceById(znode.getEndPoint().getDeviceId());
        device.setLastlogintime(System.currentTimeMillis());
        device.setStates(DeviceStatus.ONLINE.getCode());
        GWEngine.getDefaultEngine().updateDevice(device);

    }

    @Override
    public void gatewayOffLine(GatewayEvent event) throws HomeException {

    }

    @Override
    public void sensorAdding(GatewayEvent event) throws HomeException {

    }

    @Override
    public void sensorAdded(GatewayEvent event) throws HomeException {

    }

    @Override
    public void gatewaySharing(GatewayEvent event) throws HomeException {

    }

    @Override
    public void gatewayShared(GatewayEvent event) throws HomeException {

    }

    @Override
    public void stopGatewayShared(GatewayEvent event) throws HomeException {

    }

    @Override
    public void sensorRemoving(GatewayEvent event) throws HomeException {

    }

    @Override
    public void sensorRemoved(GatewayEvent event) throws HomeException {

    }

    @Override
    public void gatewayLocked(GatewayEvent event) throws HomeException {

    }

    @Override
    public void gatewayUnLocked(GatewayEvent event) throws HomeException {

    }

    @Override
    public void accountBind(GatewayEvent event) throws HomeException {

    }

    @Override
    public void accountUNBind(GatewayEvent event) throws HomeException {

    }

    @Override
    public String getSystemCode() {
        return null;
    }
}
